package org.budo.dubbo.protocol.http.exception.remoting;

import java.lang.reflect.Method;

import lombok.Setter;

import lombok.Getter;

/**
 * @author lmw
 */
@Getter
@Setter
public class ArgumentTypeMismatchException extends RemotingRuntimeException {
    private static final long serialVersionUID = 1236316504366724366L;

    private Method method;

    private Integer parameterIndex;

    private Class<?> parameterType;

    private String parameterName;

    private Object argumentValue;

    public ArgumentTypeMismatchException() {}

    public ArgumentTypeMismatchException(Method method, Integer parameterIndex, Class<?> parameterType, String parameterName, Object argumentValue) {
        this.setMethod(method);
        this.setParameterIndex(parameterIndex);
        this.setParameterType(parameterType);
        this.setArgumentValue(argumentValue);
        this.setParameterName(parameterName);
    }

    public String getMessage() {
        return "argumentValue type miss match, method is " + this.getMethod() //
                + ", parameterIndex is " + this.getParameterIndex() //
                + ", argumentValueType is " + (null == this.getArgumentValue() ? "null" : this.getArgumentValue().getClass()) //
                + ", parameterName=" + this.getParameterName() //
                + ", parameterType=" + this.getParameterType() //
                + ", argumentValue=" + this.getArgumentValue();
    }
}